package com.yuqiao.read.design.observer2java;

import java.util.Observable;

/**
 * 天氣預報數據
 */
public class WeatherData extends Observable {


    /**
     * 气温，湿度，气压
     */
    private float temp,humidity, pressure;




    void measurementsChanged(){
        setChanged();
        notifyObservers();
    }

    /**
     * 更新并通知
     * @param temp
     * @param humidity
     * @param pressure
     */
    public void setMeasurements(float temp,float humidity,float pressure){
        this.temp = temp;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }

    public float getTemp() {
        return temp;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }
}
